home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / cug191 / soundint.asl < prev    next >
Text File  |  1986-05-25  |  7KB  |  187 lines

  1. ;
  2. ;    SOUNDINT.ASM            (Lattice version)               06 Feb 86
  3. ;
  4. ;   /* ------------------------------------------------------------ */
  5. ;   /*      This is a portion of the SOUND EFFECTS LIBRARY.         */
  6. ;   /*                                                              */
  7. ;   /*      Copyright (C) 1986 by Paul Canniff.                     */
  8. ;   /*      All rights reserved.                                    */
  9. ;   /*                                                              */
  10. ;   /*      This library has been placed into the public domain     */
  11. ;   /*      by the author.  Use is granted for non-commercial       */
  12. ;   /*      pusposes, or as an IMBEDDED PORTION of a commercial     */
  13. ;   /*      product.                                                */
  14. ;   /*                                                              */
  15. ;   /*      Paul Canniff                                            */
  16. ;   /*      PO Box 1056                                             */
  17. ;   /*      Marlton, NJ 08053                                       */
  18. ;   /*                                                              */
  19. ;   /*      CompuServe ID: 73047,3715                               */
  20. ;   /*                                                              */
  21. ;   /* ------------------------------------------------------------ */
  22. ;
  23. ; -------------------------------------------------------------------------
  24. ;    Define IBM PC ports used to control speakers
  25. ;
  26. KBCTL      EQU     61H        ;Keyboard control port (controls speaker too)
  27. SPKTMR     EQU     42H        ;8253 Timer address
  28. SPKCTL     EQU     43H        ;8253 Timer address
  29. ;
  30. ; -------------------------------------------------------------------------
  31. ;    Set up macros for segment values, etc.
  32. ;
  33.     INCLUDE DOS.MAC            ;Lattice gets from file.
  34. ;
  35.     DSEG                            ;Dummy DATA Segment
  36.     ENDDS
  37. ;
  38.     IF    LPROG
  39. ARGS    EQU    6                       ;Bytes on stack before args 
  40.     ELSE
  41. ARGS    EQU    4                       ;Bytes on stack before args
  42.     ENDIF
  43. ;
  44. ; -------------------------------------------------------------------------
  45. ;
  46.         IF      LPROG
  47.     EXTRN    sound_out:FAR          
  48.     EXTRN    sound_done:FAR
  49.         ENDIF
  50. ;
  51.     PSEG                            ;Beginning of code segment
  52. ;
  53.         IF      (LPROG EQ 0)
  54.     EXTRN    sound_out:NEAR          
  55.     EXTRN    sound_done:NEAR
  56.         ENDIF
  57. ;
  58.     PUBLIC    snd_irh
  59.     PUBLIC    snd_giv
  60.     PUBLIC    snd_siv
  61.     PUBLIC    snd_brk
  62. ;
  63. ;
  64. ;
  65. snd_irh    PROC    FAR
  66.     STI                             ; Enable interrupts
  67.     PUSH    DS                      ;\
  68.     PUSH    ES                      ; \
  69.     PUSH    SI                      ;  \
  70.     PUSH    DI                      ;   \
  71.     PUSH    BP                      ; Save all registers
  72.     PUSH    AX                      ;   /
  73.     PUSH    BX                      ;  /
  74.     PUSH    CX                      ; /
  75.     PUSH    DX                      ;/
  76.     MOV    AX,SEG DGROUP           ;\
  77.     MOV    ES,AX                   ; Load expected segment values
  78.     MOV    DS,AX                   ;/
  79.     CALL    sound_out               ; Call the real code
  80.     POP    DX                      ;\
  81.     POP    CX                      ; \
  82.     POP    BX                      ;  \
  83.     POP    AX                      ;   \
  84.     POP    BP                      ; Restore all registers
  85.     POP    DI                      ;   /
  86.     POP    SI                      ;  /
  87.     POP    ES                      ; /
  88.     POP    DS                      ;/
  89.         INT     61H                     ; Call previous INT vector
  90.     IRET                            ; Return
  91. snd_irh ENDP
  92. ;
  93. ;
  94.     IF    LPROG
  95. snd_giv    PROC    FAR
  96.     ELSE
  97. snd_giv    PROC    NEAR
  98.     ENDIF
  99.     PUSH    BP                      ;Save frame pointer
  100.     MOV    BP,SP                   ;Make new frame pointer
  101.     PUSH    ES                      ;Preserve ES, just in case
  102.     XOR    AX,AX                   ;Zero ES register so it will
  103.     MOV    ES,AX                   ;   point to low memory
  104.     MOV    BX,[BP+ARGS]            ;Make BX into proper offset,
  105.     SHL    BX,1                    ;   which is the vector number
  106.     SHL    BX,1                    ;   times 4 (2 shifts)
  107.     PUSHF                           ;Save INT flag
  108.     CLI                             ;Disable interrupts
  109.     MOV    AX,ES:[BX+2]            ;Get the high ...
  110.         MOV     BX,ES:[BX]              ; ... and low words of vector
  111.     POPF                            ;Restore INT flag
  112.     POP    ES                      ;Preserve ES, just in case
  113.     POP    BP                      ;Restore caller's frame
  114.     RET
  115. snd_giv ENDP
  116. ;
  117. ;
  118.     IF    LPROG
  119. snd_siv    PROC    FAR
  120.     ELSE
  121. snd_siv    PROC    NEAR
  122.     ENDIF
  123.     PUSH    BP                      ;Save frame pointer
  124.     MOV    BP,SP                   ;Make new frame pointer
  125.     PUSH    ES                      ;Preserve ES, just in case
  126.     XOR    AX,AX                   ;Zero ES register so it will
  127.     MOV    ES,AX                   ;   point to low memory
  128.     MOV    BX,[BP+ARGS]            ;Make BX into proper offset,
  129.     SHL    BX,1                    ;   which is the vector number
  130.     SHL    BX,1                    ;   times 4 (2 shifts)
  131.     PUSHF                           ;Save INT flag
  132.     CLI                             ;Disable interrupts
  133.     MOV    AX,[BP+ARGS+2]          ;Get low word of vector 
  134.     MOV    ES:[BX],AX              ;   and install it.
  135.     MOV    AX,[BP+ARGS+4]          ;Get high word of vector
  136.     MOV    ES:[BX+2],AX            ;   and install it.
  137.     POPF                            ;Restore INT flag
  138.     POP    ES                      ;Preserve ES, just in case
  139.     POP    BP                      ;Restore caller's frame
  140.     RET
  141. snd_siv ENDP
  142. ;
  143. ;
  144. snd_brk PROC    FAR
  145.     STI
  146.     PUSH    DS                      ;\
  147.     PUSH    ES                      ; \
  148.     PUSH    SI                      ;  \
  149.     PUSH    DI                      ;   \
  150.     PUSH    BP                      ; Save all registers
  151.     PUSH    AX                      ;   /
  152.     PUSH    BX                      ;  /
  153.     PUSH    CX                      ; /
  154.     PUSH    DX                      ;/
  155.     MOV    AX,SEG DGROUP           ;\
  156.     MOV    ES,AX                   ; Load expected segment values
  157.     MOV    DS,AX                   ;/
  158.     CALL    sound_done              ; Tidy up loose ends
  159.         CLC                             ; Clear Carry (see above desc.)
  160.     INT     23H                     ; Call the real handler
  161.     POP    DX                      ;\
  162.     POP    CX                      ; \
  163.     POP    BX                      ;  \
  164.     POP    AX                      ;   \
  165.     POP    BP                      ; Restore all registers
  166.     POP    DI                      ;   /
  167.     POP    SI                      ;  /
  168.     POP    ES                      ; /
  169.     POP    DS                      ;/
  170.         JC      abort                   ; Abort if handler set carry flag
  171. ;
  172. cont:   IRET                            ; Continue, use IRET
  173. ;
  174. abort:  POPF                            ; Get flags off stack
  175.         STC                             ; Pass "abort" message back to DOS
  176.         RET                             ; Long return to DOS
  177. snd_brk ENDP
  178. ;
  179. ;
  180.     ENDPS    
  181.     END
  182.  
  183.  
  184.  
  185.  
  186.  
  187.